Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perf event array map kernel-side implementation. #4144

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

mikeagun
Copy link
Contributor

@mikeagun mikeagun commented Jan 16, 2025

Description

Implements the kernel side of perf event array maps.

Testing

Includes platform and execution context tests.

Documentation

Documented in code.

Installation

N/A

@mikeagun mikeagun marked this pull request as ready for review February 4, 2025 19:58
@mikeagun mikeagun changed the title DRAFT Perf event array map implementation. Perf event array map kernel-side implementation. Feb 4, 2025
include/ebpf_api.h Outdated Show resolved Hide resolved
include/ebpf_core_structs.h Outdated Show resolved Hide resolved
include/ebpf_extension.h Outdated Show resolved Hide resolved
libs/api/ebpf_api.cpp Outdated Show resolved Hide resolved
libs/execution_context/ebpf_core.c Outdated Show resolved Hide resolved
libs/runtime/unit/platform_unit_test.cpp Outdated Show resolved Hide resolved
libs/runtime/unit/platform_unit_test.cpp Outdated Show resolved Hide resolved
libs/runtime/unit/platform_unit_test.cpp Outdated Show resolved Hide resolved
libs/runtime/unit/platform_unit_test.cpp Outdated Show resolved Hide resolved
libs/runtime/unit/platform_unit_test.cpp Outdated Show resolved Hide resolved
return ring->consumer_offset % ring->length;
}

inline static size_t
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider refactoring. There is too much code that are near identical to the ring_buffer module. Maybe a module that is common to both??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. With some refactoring ebpf_ringbuffer (the generic implementation) could work for both perf event array and ring buffer map. Then the core maps would add the ring-buffer and perf array-specific logic.

size_t producer_offset;
uint8_t* shared_buffer;
ebpf_ring_descriptor_t* ring_descriptor;
size_t lost_records;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can the _ebpf_perf_ring "derive" from _ebpf_ring_buffer? Also see my other comment below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not directly as is - but yes.

I'm working on refactoring ebpf_ringbuffer so perf ring and the ring buffer map can both derive from ebpf_ringbuffer.

@@ -215,6 +215,9 @@ _ebpf_link_client_attach_provider(
client_dispatch_table = (void*)&_ebpf_link_dispatch_table_with_context_header;
} else {
client_dispatch_table = (void*)&_ebpf_link_dispatch_table;
// TODO: Before merging perf event array context headers must be required.
Copy link
Contributor Author

@mikeagun mikeagun Feb 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is to ensure context headers are mandatory before this PR is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants